package com.sjl.service.impl;

import com.github.pagehelper.PageHelper;
import com.sjl.dao.ProductMapper;
import com.sjl.pojo.Member;
import com.sjl.pojo.Product;
import com.sjl.pojo.SysUser;
import com.sjl.service.IProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ProductServiceImpl implements IProductService {

    @Autowired
    private ProductMapper productMapper;

    @Override
    public Product getProductByProductName(String productName) {
        Product product= productMapper.getProductByProductName(productName);
        return product;
    }

    @Override
    public List<Product> getAllProducts(String productName, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Product> allMembers = productMapper.getAllProducts(productName);
        return allMembers;
    }

    @Override
    public Product getProductById(Integer id) {
        Product product = productMapper.getProductById(id);
        return product;
    }

    @Override
    public int addProduct(Product product) {
        return productMapper.addProduct(product);
    }

    @Override
    public int editProduct(Product product) {
        int i = productMapper.editProduct(product);
        return i;
    }

    @Override
    public int deleteProductById(Integer id) {
        return productMapper.deleteProductById(id);
    }

    @Override
    public int deleteAll(List<String> ids) {
        return productMapper.deleteAll(ids);
    }


}